<template>
    <span>
        <Button type="error" size="small" @click="handleAlarmPlanDelete(data)">删除</Button>
    </span>
</template>

<script>
export default {
    name: 'AlarmPlanDeleteButton',
    props: {
        data: Object
    },
    methods: {
        handleAlarmPlanDelete(row) {
            this.$Modal.confirm({
                title: '删除确认',
                content: '确认删除该告警计划吗？',
                onOk: () => {
                    this.$http.post('/delete_alarm_plan', { plan_id: row.plan_id }).then(res => {
                        if (res.status == 'ok') {
                            this.$Message.success('删除成功');
                            this.$emit('success', res.data);
                        }else {
                            this.errorMessage(res.data);
                        }
                    }).catch(err => {
                        this.errorMessage(err.data.data);
                    });
                }
            });
        },
    }
}
</script>